package com.cs.framework.ui.builder;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;

import com.cs.framework.ui.util.UIConstant;

/**
 * 抽象UI构建
 * 
 * @author hedongzhou
 * 
 */
public abstract class AbstractUIBuilder implements UIBuilder, InitializingBean {

	protected final Log logger = LogFactory.getLog(getClass());

	public AbstractUIBuilder() {
	}

	public void afterPropertiesSet() throws Exception {
		init();
	}

	protected String[] parseId(String id) {
		String prefix = null;
		String viewId = null;

		if (!id.contains(":")) {
			prefix = UIConstant.VIEW_PATH_FOR_PAGE;
			viewId = id;
		} else {
			int separate = id.indexOf(":") + 1;
			prefix = id.substring(0, separate);
			viewId = id.substring(separate);
		}

		return new String[] { prefix, viewId };
	}

}
